import { createRouter, createWebHistory } from 'vue-router'
import MainLayout from '@/views/MainLayout.vue'
import DiscoverView from '@/views/DiscoverView.vue'
import PublishView from '@/views/PublishView.vue'
import MessagesView from '@/views/MessagesView.vue'
import ProfileView from '@/views/ProfileView.vue'
import LoginView from '@/views/LoginView.vue'
import RegisterView from '@/views/RegisterView.vue'
import NoteDetailView from '@/views/NoteDetailView.vue'
import UserProfileView from '@/views/UserProfileView.vue'
import LiveStreamView from '@/views/LiveStreamView.vue'
import PromotHomeView from '@/views/PromotHomeView.vue'
import PromotLoginView from '@/views/PromotLoginView.vue'
import PromotListView from '@/views/PromotListView.vue'
import LiveMangerView from '@/views/LiveMangerView.vue'
import LiveSessionView from '@/views/LiveSessionView.vue'
import LivePlanView from '@/views/LivePlanView.vue'
import ComputerLIveVIew from '@/views/ComputerLIveVIew.vue'
import ProfessionalView from '@/views/ProfessionalView.vue'
import PrfessionalHomeView from '@/views/PrfessionalHomeView.vue'
import CertificationView from '@/views/CertificationView.vue'
import PromotView from '@/views/PromotView.vue'
import ShoppingCartView from '@/views/ShoppingCartView.vue'
import ShopView from '@/views/ShopView.vue'
import ShopOrderView from '@/views/ShopOrderView.vue'
import MCNView from '@/views/MCNView.vue'
import BusinessViewVue from '@/views/Business​​View.vue'
import ChatViewVue from '@/views/ChatView.vue'
import MCN1Vue from '@/views/MCN-1.vue'

const routes = [
  {
    path: '/',
    component: MainLayout,
	redirect: '/discover',
    children: [
      {
        path: '/discover',
        name: 'Discover',
        component: DiscoverView,
        meta: { title: '发现' }
      },
      {
        path: '/publish',
        name: 'Publish',
        component: PublishView,
        meta: { title: '发布' }
      },
      {
        path: 'messages',
        name: 'Messages',
        component: MessagesView,
        meta: { title: '消息' }
      },
      {
        path: 'profile',
        name: 'Profile',
        component: ProfileView,
        meta: { title: '我的' }
      }
    ]
  },
  {
    path: '/login',
    name: 'Login',
    component: LoginView,
    meta: { title: '登录' }
  },
  {
    path: '/register',
    name: 'Register',
    component: RegisterView,
    meta: { title: '注册' }
  },
  {
    path: '/note/:id',
    name: 'NoteDetail',
    component: NoteDetailView,
    meta: { title: '笔记详情' }
  },
  {
    path: '/userprofile/:id',
    name: 'UserProfile',
    component: UserProfileView,
    meta: { title: '用户主页' }
  },{
    path:'/livestream',
    name:'LiveStream',
    component: LiveStreamView,
    meta: {title: '直播管理登录'}
  },{
    path: '/livemanger',
    name: 'LiveManger',
    component: LiveMangerView,
    meta: { title: '直播管理平台' },
    redirect: '/livemanger/liveplan',
    children: [
      { 
        path: 'liveplan',
        name: 'LivePlan', 
        component: LivePlanView, 
        meta: { title: '直播计划' } 
      },{ 
        path: 'livesession',
        name: 'LiveSession', 
        component: LiveSessionView, 
        meta: { title: '直播场次' } 
      }
    ]
  },{
    path: '/computerlive',
    name: 'ComputerLive',
    component: ComputerLIveVIew,
    meta: { title: '电脑直播助手' }
  },{
    path: '/professional',
    name: 'Professional',
    component: ProfessionalView,
    children:[
      {
        path: '/professionhome',
        name: 'ProfessionHome',
        component: PrfessionalHomeView,
        meta: { title: '专业号首页' }
      },{
        path: '/certification',
        name: 'Certification',
        component: CertificationView,
        meta: { title: '专业号认证' }
      }
    ]
  },
   {
      path: '/promot',
      name: 'Promot',
      component: PromotView,
	  redirect:'/promotlogin',
      children:[
        {
          path: '/promothome',
          name: 'Promothome',
          component: PromotHomeView,
          meta: { requiresAuth: true }
        },{
          path: '/promotlogin',
          name: 'Promotlogin',
          component: PromotLoginView,
          meta: { title: '登录' }
        },{
          path: '/promotlist',
          name: 'Promotlist',
          component: PromotListView,
          meta: { title: '列表' }
        }
      ]
    }
  ,{
    path: '/shop',
    name: 'shop',
    component: ShopView,
    meta: { title: '电商' }
  },{
    path: '/shopcart',
    name: 'Shopcart',
    component: ShoppingCartView,
    meta: { title: '购物车' }
  },{
    path: '/shoporder',
    name: 'Shoporderp',
    component: ShopOrderView,
    meta: { title: '订单' }
  },{
    path: '/MCN',
    name: 'MCN',
    component: MCNView,
    meta: { title: 'MCN入驻' }
  },{
	 path: '/MCN1',
	 name: 'MCN1',
	 component: MCN1Vue,
	 meta: { title: 'MCN提交' } 
  }
  ,{
    path: '/business',
    name: 'business',
    component: BusinessViewVue,
    meta: { title: '招商' }
  },{
	  path: '/chats',
	  name: 'chats',
	  component:ChatViewVue,
	  meta: { title: '聊天' }
  }
  

]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

router.beforeEach((to, from, next) => {
  document.title = to.meta.title ? `${to.meta.title} - QingBook` : 'QingBook'
  next()
})

export default router